<script type="text/html" template lay-done="layui.data.sendParams(d);">
    <div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-CoreCmsAlipayConfig-editForm" id="LAY-app-CoreCmsAlipayConfig-editForm">
        <input type="hidden" name="id" value="{{d.params.data.model.id || '' }}" />

        <div class="layui-form-item">
            <label for="appType" class="layui-form-label  layui-form-required">应用类型</label>
            <div class="layui-input-inline layui-inline-5">
                <select name="appType" lay-verify="required" placeholder="请输入应用类型" lay-reqText="请输入应用类型">
                    <option value="">请选择所属应用类型</option>
                    {{# layui.each(d.params.data.aliPayPayTradeType, function(index, item){ }}
                    <option value="{{ item.title }}" {{item.title===d.params.data.model.appType?'selected="selected"':''}}>{{ item.description }}</option>
                    {{# }); }}
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="appId" class="layui-form-label  layui-form-required">开放平台AppId</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="appId" lay-verify="required" class="layui-input" placeholder="请输入支付宝开放平台AppId" lay-reqText="请输入支付宝开放平台AppId" value="{{d.params.data.model.appId || '' }}" />
            </div>
            <div class="layui-form-mid">
                开放平台申请的应用的AppId
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label for="publicKey" class="layui-form-label  layui-form-required">支付宝公钥</label>
            <div class="layui-input-block">
                <textarea name="publicKey" id="publicKeyBox" lay-verify="required" placeholder="请输入支付宝公钥" lay-reqText="请输入支付宝公钥" class="layui-textarea">{{d.params.data.model.publicKey || '' }}</textarea>
            </div>
            <div class="layui-form-mid">
                为支付宝开放平台-支付宝公钥，支付宝支付配置为“公钥证书”方式时，留空；“普通公钥”方式时，必填。
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label for="privateKey" class="layui-form-label  layui-form-required">应用私钥</label>
            <div class="layui-input-block">
                <textarea name="privateKey" id="privateKeyBox" lay-verify="required" placeholder="请输入应用私钥" lay-reqText="请输入应用私钥" class="layui-textarea">{{d.params.data.model.privateKey || '' }}</textarea>
            </div>
            <div class="layui-form-mid">
                为“支付宝开放平台开发助手”所生成的应用私钥，请选择 PKCS1(非JAVA适用)，切记 切记 切记
            </div>
        </div>

        <div class="layui-form-item">
            <label for="serverUrl" class="layui-form-label  layui-form-required">服务网关地址</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="serverUrl" lay-verify="required" class="layui-input" placeholder="请输入服务网关地址" lay-reqText="请输入服务网关地址" value="{{d.params.data.model.serverUrl || '' }}" />
            </div>
            <div class="layui-form-mid">
                默认为正式环境地址
            </div>
        </div>

        <div class="layui-form-item">
            <label for="signType" class="layui-form-label  layui-form-required">签名类型</label>
            <div class="layui-input-inline layui-inline-8">
                <select name="signType" lay-verify="required" placeholder="请输入签名类型" lay-reqText="请输入签名类型">
                    <option value="RSA2" {{'RSA2'===d.params.data.model.signType?'selected="selected"':''}}>RSA2(SHA256WithRSA)</option>
                    <option value="RSA1" {{'RSA1'===d.params.data.model.signType?'selected="selected"':''}}>RSA1(SHA1WithRSA)</option>
                </select>
            </div>
            <div class="layui-form-mid">
                支持：RSA2(SHA256WithRSA)、RSA1(SHA1WithRSA)，默认为RSA2
            </div>
        </div>


        <div class="layui-form-item layui-form-text">
            <label for="appPublicCert" class="layui-form-label">
                应用公钥证书（证书文件的base64字符串）
                <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="doUploadAppPublicCert">
                    <i class="layui-icon">&#xe67c;</i>上传证书
                </button>
            </label>
            <div class="layui-input-block">
                <textarea name="appPublicCert" id="appPublicCertBox" placeholder="请输入应用公钥证书" lay-reqText="请输入应用公钥证书" class="layui-textarea">{{d.params.data.model.appPublicCert || '' }}</textarea>
            </div>
            <div class="layui-form-mid">
                证书文件的base64字符串，支付宝支付配置为“公钥证书”方式时，必填；“普通公钥”方式时，留空。
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label for="alipayPublicCert" class="layui-form-label">
                支付宝公钥证书（证书文件的base64字符串）
                <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="doUploadAlipayPublicCert">
                    <i class="layui-icon">&#xe67c;</i>上传证书
                </button>
            </label>
            <div class="layui-input-block">
                <textarea name="alipayPublicCert" id="alipayPublicCertBox" placeholder="请输入支付宝公钥证书" lay-reqText="请输入支付宝公钥证书" class="layui-textarea">{{d.params.data.model.alipayPublicCert || '' }}</textarea>
            </div>
            <div class="layui-form-mid">
                证书文件的base64字符串，支付宝支付配置为“公钥证书”方式时，必填；“普通公钥”方式时，留空。
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label for="alipayRootCert" class="layui-form-label">
                支付宝根证书（证书文件的base64字符串）
                <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="doUploadAlipayRootCert">
                    <i class="layui-icon">&#xe67c;</i>上传证书
                </button>
            </label>
            <div class="layui-input-block">
                <textarea name="alipayRootCert" id="alipayRootCertBox" placeholder="请输入支付宝根证书" lay-reqText="请输入支付宝根证书" class="layui-textarea">{{d.params.data.model.alipayRootCert || '' }}</textarea>
            </div>
            <div class="layui-form-mid">
                证书文件的base64字符串，支付宝支付配置为“公钥证书”方式时，必填；“普通公钥”方式时，留空。
            </div>
        </div>


        <div class="layui-form-item">
            <label for="notifyUrl" class="layui-form-label  layui-form-required">支付通知地址</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="notifyUrl" lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入支付宝支付回调通知" lay-reqText="请输入支付宝支付回调通知" value="{{d.params.data.model.notifyUrl || '' }}" />
            </div>
            <div class="layui-form-mid">
                接口地址+【/Notify/AliPay/Unifiedorder】
            </div>
        </div>

        <div class="layui-form-item">
            <label for="refundUrl" class="layui-form-label  layui-form-required">退款回调地址</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="refundUrl" lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入支付宝退款回调" lay-reqText="请输入支付宝退款回调" value="{{d.params.data.model.refundUrl || '' }}" />
            </div>
            <div class="layui-form-mid">
                接口地址+【/Notify/AliPay/Refund】
            </div>
        </div>

        <div class="layui-form-item">
            <label for="jumpUrl" class="layui-form-label">支付后跳转地址</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="jumpUrl" lay-verType="tips" class="layui-input" placeholder="请输入支付跳转地址" lay-reqText="请输入支付跳转地址" value="{{d.params.data.model.jumpUrl || '' }}" />
            </div>
            <div class="layui-form-mid">
                一般只有h5和pc端有，接口地址+【/order/payment/result】
            </div>
        </div>

        <div class="layui-form-item">
            <label for="isEnable" class="layui-form-label  layui-form-required">是否启用</label>
            <div class="layui-input-inline layui-inline-4">
                <input type="checkbox" lay-filter="switch" name="isEnable" {{ d.params.data.model.isEnable ? 'checked' : '' }} lay-skin="switch" lay-text="开启|关闭">
            </div>
            <label for="isDefault" class="layui-form-label  layui-form-required">当前多端默认</label>
            <div class="layui-input-inline layui-inline-4">
                <input type="checkbox" lay-filter="switch" name="isDefault" {{ d.params.data.model.isDefault ? 'checked' : '' }} lay-skin="switch" lay-text="开启|关闭">
            </div>
        </div>

        <div class="layui-form-item text-right core-hidden">
            <input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-CoreCmsAlipayConfig-editForm-submit" id="LAY-app-CoreCmsAlipayConfig-editForm-submit" value="确认编辑">
        </div>
    </div>
</script>
<script>
    var debug = layui.setter.debug;
    layui.data.sendParams = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d.params.data); }
        layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
            function () {
                var $ = layui.$
                    , form = layui.form
                    , admin = layui.admin
                    , laydate = layui.laydate
                    , upload = layui.upload
                    , cropperImg = layui.cropperImg
                    , coreHelper = layui.coreHelper;



                var upload = layui.upload;

                //执行实例
                upload.render({
                    elem: '#doUploadAppPublicCert' //绑定元素
                    , auto: false
                    , accept: 'file'
                    , exts: 'p12'
                    , choose: function (obj) {
                        obj.preview(function (index, file, result) {
                            var base64 = result.substring(result.indexOf(',') + 1)
                            $('#appPublicCertBox').val(base64);
                            form.render(null, 'LAY-app-CoreCmsAlipayConfig-editForm');
                        });
                    }, error: function () {
                        //请求异常回调
                    }
                });

                upload.render({
                    elem: '#doUploadAlipayPublicCert' //绑定元素
                    , auto: false
                    , accept: 'file'
                    , exts: 'p12'
                    , choose: function (obj) {
                        obj.preview(function (index, file, result) {
                            var base64 = result.substring(result.indexOf(',') + 1)
                            $('#alipayPublicCertBox').val(base64);
                            form.render(null, 'LAY-app-CoreCmsAlipayConfig-editForm');
                        });
                    }, error: function () {
                        //请求异常回调
                    }
                });

                upload.render({
                    elem: '#doUploadAlipayRootCert' //绑定元素
                    , auto: false
                    , accept: 'file'
                    , exts: 'p12'
                    , choose: function (obj) {
                        obj.preview(function (index, file, result) {
                            var base64 = result.substring(result.indexOf(',') + 1)
                            $('#alipayRootCertBox').val(base64);
                            form.render(null, 'LAY-app-CoreCmsAlipayConfig-editForm');
                        });
                    }, error: function () {
                        //请求异常回调
                    }
                });



                form.verify({

                });
                //重载form
                form.render(null, 'LAY-app-CoreCmsAlipayConfig-editForm');
            })
    };
</script>
